/**InsertEntityLib.js v.0.0.1******************************************
 *author: basanas 
 **********************************************************************/
$.ajaxSetup({ cache: false });

function passData(attrNum)
{
    if (document.getElementById('entityName').value.length == 0)
    {
        $("#msg-box").html("<div class=\"msgbox-warning\"><ul><li>Entity doesn't have a name. Please insert one.</li></ul></div>");
    }
    //else if(TODO)
    //	$("#msg-box").html("<div class=\"msgbox-warning\"><ul><li>A entity with the same name exists. Please choose a different name.</li></ul></div>");
    else if (checkAttrs(attrNum) == false)
    {
        $("#msg-box").html("<div class=\"msgbox-warning\"><ul><li>At least one attribute must be completed.</li></ul></div>");
    }
    else
    {
        document.insertEntity.submit();
    }
} /* At least one attribute must be non-empty */

function checkAttrs(attrNum)
{
    var i;
    for (i = 0; i < attrNum; i++)
    {
        if (document.getElementById("attr" + i).value.length != 0) return true;
    }
    return false;
}